<template>
	<view class="login-container">
		<!-- Logo区域 -->
		<view class="logo-section animate-slide-in">
			<image src="/static/logo.png" mode="aspectFit" class="logo-image"></image>
			<text class="text-h1">驰锐电子</text>
			<text class="text-muted">欢迎回来</text>
		</view>

		<!-- 登录表单 -->
		<view class="login-form card shadow animate-slide-in" style="animation-delay: 0.1s;">
			<view class="input-group">
				<view class="input-item">
					<uni-icons type="person" size="20" ></uni-icons>
					<input type="text" v-model="form.username" placeholder="请输入用户名/手机号" placeholder-class="placeholder" />
				</view>
				<view class="input-item">
					<uni-icons type="locked" size="20" ></uni-icons>
					<input :type="showPassword ? 'text' : 'password'" v-model="form.password" placeholder="请输入密码" placeholder-class="placeholder" />
					<view class="password-icon" @click="togglePasswordVisibility">
						<uni-icons :type="showPassword ? 'eye-filled' : 'eye-slash-filled'" size="20" color="#95afc0"></uni-icons>
					</view>
				</view>
			</view>

			<view class="options-row">
				<label class="remember-password flex">
					<checkbox :checked="rememberPassword" @tap="toggleRememberPassword"  style="transform:scale(0.7)" />
					<text class="text-muted">记住密码</text>
				</label>
				<text class="text-primary" @click="handleForgotPassword">忘记密码？</text>
			</view>

			<button class="btn btn-primary w-full mb-3" @click="handleLogin" :loading="loading">
				{{ loading ? '登录中...' : '登录' }}
			</button>

			<!-- 其他登录方式 -->
			<view class="other-login">
				<view class="divider">
					<view class="line"></view>
					<text class="text-muted">其他登录方式</text>
					<view class="line"></view>
				</view>
				<view class="login-methods flex-center">
					<view class="method-item" @click="handleOtherLogin('wechat')">
						<uni-icons type="weixin" size="28" ></uni-icons>
						<text class="text-muted">微信</text>
					</view>
					<!-- <view class="method-item" @click="handleOtherLogin('phone')">
						<uni-icons type="phone" size="28" ></uni-icons>
						<text class="text-muted">手机号</text>
					</view> -->
				</view>
			</view>

			<view class="register-link text-center mt-3">
				<text class="text-muted">还没有账号？</text>
				<text class="text-primary" @click="goToRegister">立即注册</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					username: '',
					password: ''
				},
				showPassword: false,
				rememberPassword: false,
				loading: false
			}
		},
		methods: {
			togglePasswordVisibility() {
				this.showPassword = !this.showPassword
			},
			toggleRememberPassword() {
				this.rememberPassword = !this.rememberPassword
			},
			handleLogin() {
				if (!this.form.username || !this.form.password) {
					uni.showToast({
						title: '请输入用户名和密码',
						icon: 'none'
					})
					return
				}
				
				this.loading = true
				// 模拟登录请求
				setTimeout(() => {
					this.loading = false
					uni.switchTab({
						url: '/pages/index/index'
					})
				}, 1500)
			},
			handleForgotPassword() {
				uni.navigateTo({
					url: '/pages/forgot-password/index'
				})
			},
			handleOtherLogin(type) {
				// 处理其他登录方式
				console.log('其他登录方式:', type)
			},
			goToRegister() {
				uni.navigateTo({
					url: '/pages/register/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.login-container {
	min-height: 100vh;
	padding: 60rpx 40rpx;
	background: linear-gradient(135deg, #ebf5fb 0%, #ffffff 100%);
}

.logo-section {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-bottom: 80rpx;
	
	.logo-image {
		width: 180rpx;
		height: 180rpx;
		margin-bottom: 30rpx;
		filter: drop-shadow(0 4rpx 10rpx rgba(0, 0, 0, 0.1));
	}
}

.login-form {
	.input-group {
		margin-bottom: 30rpx;
	}

	.input-item {
		display: flex;
		align-items: center;
		padding: 16rpx 20rpx;
		border-bottom: 2rpx solid var(--border-color);
		
		&:last-child {
			border-bottom: none;
		}
		
		input {
			flex: 1;
			margin-left: 20rpx;
			font-size: 28rpx;
			color: var(--text-primary);
			background: transparent;
			border: none;
			height: 60rpx;
			
			&:focus {
				box-shadow: none;
			}
		}
		
		.password-icon {
			padding: 10rpx;
		}
	}

	.placeholder {
		color: var(--text-muted);
		font-size: 28rpx;
	}
}

.options-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 40rpx;
	padding: 0 10rpx;
	
	.remember-password {
		text {
			margin-left: 8rpx;
		}
	}
}

.other-login {
	margin: 60rpx 0 40rpx;
	
	.divider {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-bottom: 40rpx;
		
		.line {
			flex: 1;
			height: 1rpx;
			background: var(--border-color);
		}
		
		text {
			margin: 0 20rpx;
			font-size: 24rpx;
		}
	}
}

.login-methods {
	gap: 60rpx;
	
	.method-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 10rpx;
		padding: 20rpx;
		border-radius: 16rpx;
		transition: all 0.3s ease;
		
		&:active {
			background: rgba(52, 152, 219, 0.1);
			transform: translateY(2rpx);
		}
		
		text {
			font-size: 24rpx;
		}
	}
}

.w-full {
	width: 100%;
}

.text-center {
	text-align: center;
}

.btn-primary {
	background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
	color: #fff;
	border: none;
	border-radius: var(--radius);
	font-size: var(--font-size);
	font-weight: 500;
	box-shadow: 0 4rpx 12rpx rgba(52, 152, 219, 0.2);
	transition: all 0.3s ease;
	
	&:active {
		transform: translateY(2rpx);
		box-shadow: 0 2rpx 6rpx rgba(52, 152, 219, 0.1);
	}
}

.text-primary {
	color: #3498db;
}
</style> 